﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Data;


namespace DocManagerControls.Converters
{
    public class ConverterExtToImage : IValueConverter 
    {
       string  extFile= string.Empty;
       //Uri("pack://application:,,,/ApplicationName;component/Resources/logo.png"); 

        public object Convert(object value, Type targeTtype, object parameter, System.Globalization.CultureInfo culture)            
        {
            extFile = value.ToString();
            BitmapImage logo = new BitmapImage();
            logo.BeginInit();

            switch (extFile)
            {
                case ".doc":
                    return @"..\IMG\docPicc.gif";
                    //return @"/DocManagerControls;component/Img/docPicc.gif";
                    //logo.UriSource = new Uri(@"/DocManagerControls;component/Img/docPicc.jpg") ;                                      
                    break;
                case ".xls":
                    return @"..\IMG\xlsPicc.gif";
                    break;
                case ".pdf":
                    return @"..\IMG\pdfPicc.gif";
                    break;
                case ".txt":
                    return @"..\IMG\txtPicc.gif";
                    break;
                case ".rtf":
                    return @"..\IMG\rtf.png";
                    break;
                case ".mdb":
                    return @"..\IMG\mdb.gif";
                    break;
                default:
                    return null;
                    break;
            }

            logo.EndInit();
            Image finalImage = new Image();
            finalImage.Width = 80;
            finalImage.Source = logo;
            return finalImage;

        }


        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }//fM
}
